<?php
declare (strict_types = 1);

namespace app\command;

use app\models\WxMessageRecords;
use app\services\WxService;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;

class SendWxMessage extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('send:wxMessage')
            ->setDescription('发送微信模版消息');
    }

    protected function execute(Input $input, Output $output)
    {

        // 指令输出
        $records = WxMessageRecords::where(['status' => 0])->limit(100)->select();

        foreach ($records as $record) {
            $data = [
                'date2' => [
                    'value' => date('Y-m-d H:i:s')
                ],
                'thing6' => [
                    'value' => '新的一周元气满满，本周别忘了答题哦，每周有4次答题机会哦'
                ]
            ];
            (new WxService())->sendMessage($record, $data);
        }
    }
}
